package com.example.feiyu.driveronline;

import android.content.Context;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageButton;
import android.widget.TextView;

import com.example.feiyu.driveronline.adapter.RankingAdapter;
import com.example.feiyu.driveronline.domain.RankingItem;
import com.example.feiyu.driveronline.utils.GetTestData;

import java.util.List;

public class RankingActivity extends AppCompatActivity {

    private List<RankingItem> ranklist;

    private ImageButton backward_ib;
    private ImageButton more_ib;
    private RecyclerView rankList_rv;
    private TextView title_name_tv;

    private void initView(){
        backward_ib= (ImageButton) findViewById(R.id.backward_ib);
        backward_ib.setVisibility(View.VISIBLE);
        backward_ib.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        more_ib = (ImageButton) findViewById(R.id.more_ib);
        more_ib.setVisibility(View.GONE);
        rankList_rv= (RecyclerView) findViewById(R.id.ranking_driver_rv);
        title_name_tv = (TextView) findViewById(R.id.title_tv);
        title_name_tv.setText("排名");

        ranklist = GetTestData.getTestRankingList();
        RankingAdapter adapter = new RankingAdapter(ranklist);
        LinearLayoutManager layoutManager = new LinearLayoutManager(this);
        rankList_rv.setLayoutManager(layoutManager);
        rankList_rv.setAdapter(adapter);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_ranking);
        initView();
    }

    public static void actionStart(Context context, Long driver_id){
        Intent intent = new Intent(context,RankingActivity.class);
        intent.putExtra("driver_id",driver_id);
        context.startActivity(intent);
    }
}
